<?php
namespace app\serverqrcode\service\qrcode;
use \app\manage\service\ApiBase;
use \think\Validate;

class ApiQrCode extends ApiBase
{
    protected $addFields = ["token"=>"", "appkey"=>"", "type"=>"", "code_id"=>"", "url"=>"", "size"=>""];
    protected $qrcodeValidate = 'app\serverqrcode\validate\QrCode';
    protected $qrcodeLogic    = '\app\serverqrcode\logic\QrCode';

    //生成二维码 可设置大小
    public function createQrCode()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData($this->addFields);
        return $this->stepRun($data,'createQrCode','add',$this->qrcodeValidate,$this->qrcodeLogic);
    }

    //获取二维码
    public function gainQrCode()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData(["token"=>"", "appkey"=>"", "type"=>"", "code_id"=>""]);
        return $this->stepRun($data,'gainQrCode','gain',$this->qrcodeValidate,$this->qrcodeLogic);
    }
}